

//遍历容器内的图片
function identifyImages(){
    //找到容器元素
    var box = $('.comment-container .item .right .content');
    box.find("img").each(function(){
        //找到最近的包含.img-group的父元素的.img-group元素
        var imgGroup = $(this).closest('.content').find('.img-group');
        //添加类名
        $(this).addClass("file-item");
        //移动到容器末尾
        $(this).appendTo(imgGroup);
    })
    //图片弹出层
    layer.photos({
        photos: '.comment-container .item .right .content',
    });
}


function scrollBottom(){
    var scrollHeight = $('#log-list').prop("scrollHeight");
    $('#log-list').animate({scrollTop:scrollHeight}, 0);
}

//进去页面先执行一次检测
identifyImages();
//进入页面先执行一次滚动 
scrollBottom();

function reply()
{
    //获取任务ID
    let nid     = $('input[name="nid"]').val();
    //获取人员ID
    let user_id = $('input[name="user_id"]').val();
    //获取输入内容 
    let content = $('#ai_content').val();

    //获取需要通知的人
    let obj = document.getElementsByName("ai_notice_member");
    notice_member = [];
    for(k in obj){
        if(obj[k].checked)
            notice_member.push(obj[k].value);
    }

    $.post('https://oa.vanzetech.com/controller/extender/task/controller/reply-add.php', { 
        nid: nid,
        content: content,
        user_id: user_id,
        notice_member:notice_member
    }, function(msg) {
        msg = $.trim(msg);

        //移除暂无消息提示
        $('#no-data').remove();
        //将返回的HTML输出到页面
        $(".comment-list").append(msg);
        //清空输入框值
        KindEditor.instances[0].html("");
        //检测新插入的图片并更改样式
        identifyImages();
        //滚动到最底部
        scrollBottom();
    });

}
